//检测当前状态
var urlList = mw.config.get('ucenterSynloginUrl');

function loadScriptPromise(src){
	return new Promise((resolve, reject) => {
		$.getScript(src, (a, status, event) => {
			if(status === 'success'){
				resolve(event);
			} else {
				reject(event);
			}
		});
	});
}

if(urlList){ //加载同步登录脚本
	if(Array.isArray(urlList)){
		var loadQueue = [];
		urlList.forEach((url) => {
			loadQueue.push(loadScriptPromise(url));
		});
		Promise.all(loadQueue).then(() => { //同步登录完成
			var api = new mw.Api();
			api.get({'action': 'synloginfinish'});
		});
	}
}